// ID: B0201
package git.bankview.wl.servlet;

import java.io.*;
import java.util.*;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;

import org.apache.log4j.Logger;

import laya.util.*;

import git.bankview.sl.Globals;
import git.bankview.sl.report.ReportCommon;

/**
 *
 * @version v0.00.0024
 * @author BJ L.Shuang(2004/05/07)
 */
public class AccessoryDownloadServlet extends SingleFileDownloadServlet
{
	private static Logger log = Logger.getLogger(AccessoryDownloadServlet.class);

	/**
	 *
	 * @param request Request
	 * @param response Response
	 * @see #doGet(HttpServletRequest,HttpServletResponse)
	 */
	protected File resolveRequestedFile(HttpServletRequest request)
		throws ServletException, IOException
	{
		String oSrcPath = request.getRequestURI();
		log.debug("handle accessory download request: " + oSrcPath);
		int spltrIdx = oSrcPath.lastIndexOf("/");
		
		String oAccessoryName = oSrcPath.substring(spltrIdx + 1);
		String oTransid = oSrcPath.substring(spltrIdx - 5, spltrIdx);
		String oPathname = ReportCommon.JASPER_DIR + oTransid + "/" + new File(oAccessoryName).getName();
		log.debug("accessory pathname: " + oPathname);
		return new File(oPathname);
	}
}
